package example.controller;

import example.aop.NewExpResponse;
import example.handler.MoneyHandler;
import example.param.MoneyConsumeParam;
import example.param.MoneyPayParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by snksnk1091 on 2017/8/23.
 */
@Controller
@RequestMapping("/Money")
public class MoneyController {

    @Autowired
    private MoneyHandler moneyHandler;

    @ResponseBody
    @NewExpResponse
    @RequestMapping("/pay")
    public Object pay(@RequestBody MoneyPayParam param){
        return moneyHandler.pay(param);
    }

    @ResponseBody
    @NewExpResponse
    @RequestMapping("/consume")
    public Object consume(@RequestBody MoneyConsumeParam param){
        return moneyHandler.consume(param);
    }

    @ResponseBody
    @NewExpResponse
    @RequestMapping("/checkMoneyList/{userName}")
    public Object checkMoneyList(@PathVariable String userName){
        return moneyHandler.getMoneyListByName(userName);
    }

    @ResponseBody
    @NewExpResponse
    @RequestMapping("/checkAllMoneyList")
    public Object checkAllMoneyList(){
        return moneyHandler.getAllMoneyList();
    }
}
